package com.lovo.service.impl;


import com.lovo.dto.SysGoodsDto;
import com.lovo.dto.TenderDto;

import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MQSService {

    @Autowired
    RabbitTemplate rabbitTemplate;

    public void sendTender(TenderDto tenderDto) {
        rabbitTemplate.setMandatory(true);
        CorrelationData correlationData = new CorrelationData("ok");
        rabbitTemplate.convertAndSend("directExchangeTender", "tender.key", tenderDto, correlationData);
    }


    public void sendGoods(SysGoodsDto sysGoodsDto) {
        rabbitTemplate.setMandatory(true);
        CorrelationData correlationData = new CorrelationData("ok");
        rabbitTemplate.convertAndSend("directExchangeGoods", "goods.key", sysGoodsDto, correlationData);
    }

}
